<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The CachingIterator class</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="arrayiterator.valid.html">ArrayIterator::valid</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="cachingiterator.construct.html">CachingIterator::__construct</a></div>
 <div class="up"><a href="spl.iterators.html">迭代器</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="class.cachingiterator" class="reference">
 <h1 class="title">The CachingIterator class</h1>
 
 
 <div class="partintro"><p class="verinfo">(PHP 5)</p>
 

  <div class="section" id="cachingiterator.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    This object supports cached iteration over another iterator.
   </p>
  </div>

 
  <div class="section" id="cachingiterator.synopsis">
   <h2 class="title">类摘要</h2>
 

   <div class="classsynopsis">
    <div class="ooclass"></div>
 

    <div class="classsynopsisinfo">
     <span class="ooclass">
      <strong class="classname">CachingIterator</strong>
     </span>

     <span class="ooclass">
      <span class="modifier">extends</span>
      <a href="class.iteratoriterator.html" class="classname">IteratorIterator</a>
     </span>

     <span class="oointerface">implements 
      <span class="interfacename"><a href="class.outeriterator.html" class="interfacename">OuterIterator</a></span>
     </span>
 
     <span class="oointerface">, 
      <span class="interfacename"><strong class="interfacename">ArrayAccess</strong></span>
     </span>
 
     <span class="oointerface">, 
      <span class="interfacename"><a href="class.countable.html" class="interfacename">Countable</a></span>
     </span>
     {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 常量 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.cachingiterator.html#cachingiterator.constants.call-tostring"><var class="varname">CALL_TOSTRING</var></a></var>
     <span class="initializer"> = 1</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.cachingiterator.html#cachingiterator.constants.catch-get-child"><var class="varname">CATCH_GET_CHILD</var></a></var>
     <span class="initializer"> = 16</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.cachingiterator.html#cachingiterator.constants.tostring-use-key"><var class="varname">TOSTRING_USE_KEY</var></a></var>
     <span class="initializer"> = 2</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.cachingiterator.html#cachingiterator.constants.tostring-use-current"><var class="varname">TOSTRING_USE_CURRENT</var></a></var>
     <span class="initializer"> = 4</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.cachingiterator.html#cachingiterator.constants.tostring-use-inner"><var class="varname">TOSTRING_USE_INNER</var></a></var>
     <span class="initializer"> = 8</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.cachingiterator.html#cachingiterator.constants.full-cache"><var class="varname">FULL_CACHE</var></a></var>
     <span class="initializer"> = 256</span>
    ;</div>

    
    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="cachingiterator.construct.html" class="methodname">__construct</a></span>
    ( <span class="methodparam"><span class="type"><a href="class.iterator.html" class="type Iterator">Iterator</a></span> <code class="parameter">$iterator</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$flags</code><span class="initializer"> = self::CALL_TOSTRING</span></span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">int</span><span class="methodname"><a href="cachingiterator.count.html" class="methodname">count</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="cachingiterator.current.html" class="methodname">current</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="cachingiterator.getcache.html" class="methodname">getCache</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="cachingiterator.getflags.html" class="methodname">getFlags</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">Iterator</span><span class="methodname"><a href="cachingiterator.getinneriterator.html" class="methodname">getInnerIterator</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="cachingiterator.hasnext.html" class="methodname">hasNext</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">scalar</span><span class="methodname"><a href="cachingiterator.key.html" class="methodname">key</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="cachingiterator.next.html" class="methodname">next</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="cachingiterator.offsetexists.html" class="methodname">offsetExists</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$index</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="cachingiterator.offsetget.html" class="methodname">offsetGet</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$index</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="cachingiterator.offsetset.html" class="methodname">offsetSet</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$index</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$newval</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="cachingiterator.offsetunset.html" class="methodname">offsetUnset</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$index</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="cachingiterator.rewind.html" class="methodname">rewind</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="cachingiterator.setflags.html" class="methodname">setFlags</a></span>
    ( <span class="methodparam"><span class="type"><span class="type bitmask">bitmask</span></span> <code class="parameter">$flags</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="cachingiterator.tostring.html" class="methodname">__toString</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">void</span><span class="methodname"><a href="cachingiterator.valid.html" class="methodname">valid</a></span>
    ( <span class="methodparam">void</span>
   )</div>


   }</div>


  </div>
  

  <div class="section" id="cachingiterator.constants">
   <h2 class="title">预定义常量</h2>
   <dl>


    
     <dt id="cachingiterator.constants.call-tostring"><strong><code>CachingIterator::CALL_TOSTRING</code></strong></dt>

     <dd>

      <p class="para">Convert every element to string.</p>
     </dd>

    

    
     <dt id="cachingiterator.constants.catch-get-child"><strong><code>CachingIterator::CATCH_GET_CHILD</code></strong></dt>

     <dd>

      <p class="para">Don&#039;t throw exception in accessing children.</p>
     </dd>

    

    
     <dt id="cachingiterator.constants.tostring-use-key"><strong><code>CachingIterator::TOSTRING_USE_KEY</code></strong></dt>

     <dd>

      <p class="para">
       Use <a href="cachingiterator.key.html" class="link">key</a> for conversion to
       string.
      </p>
     </dd>

    

    
     <dt id="cachingiterator.constants.tostring-use-current"><strong><code>CachingIterator::TOSTRING_USE_CURRENT</code></strong></dt>

     <dd>

      <p class="para">
       Use <a href="cachingiterator.current.html" class="link">current</a> for
       conversion to string.</p>
     </dd>

    

    
     <dt id="cachingiterator.constants.tostring-use-inner"><strong><code>CachingIterator::TOSTRING_USE_INNER</code></strong></dt>

     <dd>

      <p class="para">
       Use <a href="cachingiterator.getinneriterator.html" class="link">inner</a>
       for conversion to string.
      </p>
     </dd>

    

    
     <dt id="cachingiterator.constants.full-cache"><strong><code>CachingIterator::FULL_CACHE</code></strong></dt>

     <dd>

      <p class="para">Cache all read data.</p>
     </dd>

    

   </dl>

  </div>



 </div>
 
 























































































































 
<h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="cachingiterator.construct.html">CachingIterator::__construct</a> — Construct a new CachingIterator object for the iterator.</li><li><a href="cachingiterator.count.html">CachingIterator::count</a> — The number of elements in the iterator</li><li><a href="cachingiterator.current.html">CachingIterator::current</a> — Return the current element</li><li><a href="cachingiterator.getcache.html">CachingIterator::getCache</a> — The getCache purpose</li><li><a href="cachingiterator.getflags.html">CachingIterator::getFlags</a> — Get flags used</li><li><a href="cachingiterator.getinneriterator.html">CachingIterator::getInnerIterator</a> — Returns the inner iterator</li><li><a href="cachingiterator.hasnext.html">CachingIterator::hasNext</a> — Check whether the inner iterator has a valid next element</li><li><a href="cachingiterator.key.html">CachingIterator::key</a> — Return the key for the current element</li><li><a href="cachingiterator.next.html">CachingIterator::next</a> — Move the iterator forward</li><li><a href="cachingiterator.offsetexists.html">CachingIterator::offsetExists</a> — The offsetExists purpose</li><li><a href="cachingiterator.offsetget.html">CachingIterator::offsetGet</a> — The offsetGet purpose</li><li><a href="cachingiterator.offsetset.html">CachingIterator::offsetSet</a> — The offsetSet purpose</li><li><a href="cachingiterator.offsetunset.html">CachingIterator::offsetUnset</a> — The offsetUnset purpose</li><li><a href="cachingiterator.rewind.html">CachingIterator::rewind</a> — Rewind the iterator</li><li><a href="cachingiterator.setflags.html">CachingIterator::setFlags</a> — The setFlags purpose</li><li><a href="cachingiterator.tostring.html">CachingIterator::__toString</a> — Return the string representation of the current element</li><li><a href="cachingiterator.valid.html">CachingIterator::valid</a> — Check whether the current element is valid</li></ul>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="arrayiterator.valid.html">ArrayIterator::valid</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="cachingiterator.construct.html">CachingIterator::__construct</a></div>
 <div class="up"><a href="spl.iterators.html">迭代器</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
